<?php
/**
 * Author: Hancock
 * Email: 84622365@qq.com
 * Date: 3/23/2016
 * Des: 数据库
 */
defined('INHkMvc') or exit('Access Invalid!');
class DB{
    public static $db;
    public static $config;
    public static function init($dbType, $config){
        self::$db = Factory::register($dbType, "db");
        self::$db->connect(Config::dbConfig($config));
    }
    public static function selectDb($db){
        return self::$db->selectDb($db);
    }
    public static function setCharset($charset = "utf8"){
        return self::$db->setCharset($charset);
    }
    public static function query($sql){
        return self::$db->query($sql);
    }
    public static function affectedRows(){
        return self::$db->affectedRows();
    }
    public static function fetchAssoc($sql){
        return self::$db->fetchAssoc($sql);
    }
    public static function fetchArray($sql){
        return self::$db->fetchArray($sql);
    }
    public static function fetchAll($sql){
        return self::$db->fetchAll($sql);
    }
    public static function begin(){
        return self::$db->begin();
    }
    public static function commit(){
        return self::$db->commit();
    }
    public static function rollback(){
        return self::$db->rollback();
    }
    public static function numRows($sql){
        return self::$db->numRows($sql);
    }
    public static function insertId(){
        return self::$db->insertId();
    }
    public static function threadId(){
        return self::$db->threadId();
    }
    public static function kill($id){
        return self::$db->kill($id);
    }
    public static function serverInfo(){
        return self::$db->serverInfo();
    }
    public static function error(){
        return self::$db->error();
    }
    public static function close(){
        return self::$db->close();
    }
}
